// ===============================================
// users_api
//
// Create by will on 8/3/2024 16:44
// Copyright @polynesia.All rights reserved.
// ===============================================

import 'package:dio/dio.dart';
import 'package:retrofit/dio.dart';
import 'package:retrofit/error_logger.dart';
import 'package:retrofit/http.dart';

import '../../../const/env_config.dart';
import '../../../http/dior.dart';
import '../entity/login_info.dart';
import '../entity/user_entity.dart';

part 'users_api.g.dart';

@RestApi(baseUrl: '')
abstract class UsersApi {
  factory UsersApi(Dio dio, {String baseUrl}) = _UsersApi;

  static UsersApi acquire() {
    return UsersApi(Dior.appDio, baseUrl: Env().envConfig.baseUrl ?? '');
  }

  @POST('/api/v1/user/login')
  Future<LoginInfo> login({
    @DioOptions() Options? options,
    @CancelRequest() CancelToken? cancelToken,
    @SendProgress() ProgressCallback? onSendProgress,
    @ReceiveProgress() ProgressCallback? onReceiveProgress,
    @Field('account') String? account,
    @Field('password') String? password,
    @Field('account_type') String? accountType,
    @Field('country_code') String? countryCode,
  });

  @POST('/api/v1/user/read')
  Future<UserEntity> read({
    @DioOptions() Options? options,
    @CancelRequest() CancelToken? cancelToken,
    @SendProgress() ProgressCallback? onSendProgress,
    @ReceiveProgress() ProgressCallback? onReceiveProgress,
    @Field('user_id') int? userId,
  });
}
